/*
                    Chatbox Class Definition
*/

#ifndef CHATBOX_H
#define CHATBOX_H

#include <stdio.h>
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_rotozoom.h"
#include <string>
#include "SDL/SDL_ttf.h"

#include "../Structs.h"
#include "../Functions.h"

#include "Widget.h"

#include "VScrollbar.h"

#define LINE_SPACING 1

using namespace std;

class Chatbox : public Widget
{
    public:
        Chatbox();
        ~Chatbox();

        int Initialise(Point NewPosition, string strFontFilepath, int iNewSize,
                           int iWidth, int iHeight, int iNewMaxLines);

        int HandleMouseDown(int iMouseX, int iMouseY);
        int HandleMouseUp(int iMouseX, int iMouseY);
        int HandleMouseMotion(int iMouseXREL, int iMouseYREL);

        int AddMessage(string strPlayer, UnicodeString ustrMessage, SDL_Colour MessageColour);

        int BlitToSurface(SDL_Surface *surface) {}
        int BlitToFrame(SDL_Surface *surface, Point FramePosition);

        int getMaxLines();

        bool getAutoscroll();
        void setAutoscroll(const bool& bNewAutoscroll);

    private:
        TTF_Font *MessageFont;

        int iMaxLines;
        int iTextSize;
        int iCurrentLine;
        int iWidth, iHeight;

        bool bAutoscroll;

        vector<SDL_Surface*> Lines;

        int iTotalHeight;

        Point Position;

        VScrollbar Scrollbar;

        void Update();

        void AddLine(UnicodeString ustrLine, const SDL_Color& MessageColour);
};

#endif
